function onloadHandler(as){
	Proj = Ao.$("#com.esri.ags.utils.WebMercatorUtil");
	CarSymbol = Ao.$("com.esri.ags.symbols.CompositeSymbol",{
		symbols:[
			Ao.$("com.esri.ags.symbols.PictureMarkerSymbol",{
				source:"resources/images/car.gif",
				width:25,height:25
			}),
			Ao.$("com.esri.ags.symbols.TextSymbol",{
				textAttribute:"CarNo",
        		color:0x0000ff,
        		yoffset:10,
        		placement:"start"
			})
		]
	});

	as.getLayer("satellite").attr("remoteTiles",{"satellite":"http://khm2.google.com/kh/v=101&"});

	//设置初始区域
	this.extent([13193921.651217777,3755988.2359406906,13259007.780802589,3786486.6102264677]);
};

function gps(callback){
	$.getJSON("../ajax/getGPS",callback);
};

//登录后的处理
function loginBack(){
	Ext.getCmp("carlistCMP").getStore().load();//加载车辆列表
	Ext.getCmp("pcdlistCMP").getStore().load();//加载

	gps(function(data){
		console.log(data);
	});
};

//绘制Gps车辆位置
GPS = {};

function drawGps(records){
	var len = records.length
	for(var i=0;i<len;i++){
		var data = records[i].data;
		var x = data.fJingDu/100000;
		var y = data.fWeiDu/100000;
		var id = data.CarID.toString();
		var mp = Ao.$("com.esri.ags.geometry.MapPoint",{x:x,y:y});
		mp = Proj.geographicToWebMercator(mp);
		//console.log(mp);

		var graphic = GPS[id];

		if(!graphic){
			graphic = Ao.$("com.esri.ags.Graphic",{
				geometry:mp,
				attributes:data,
				symbol:CarSymbol
			});
			GPS[id] = graphic;

			graphic.addEventListener("click",graphicClickHandler);

			map.clientLayer.add(graphic);
		}else{
			graphic.attr({
				geometry:mp,
				attributes:data,
				symbol:CarSymbol
			});
			graphic.refresh();
		}

		//map.clientLayer.add(graphic);
	}
};

function graphicClickHandler(event){
	var geom = event.attr("currentTarget.geometry");
	var pixel = map.AS.toScreen(geom);
};